home *** CD-ROM | disk | FTP | other *** search
/ Aminet 33 / Aminet 33 - October 1999.iso / Aminet / comm / misc / statickyupdate.lha / statickyupdate.rexx < prev   
Encoding:
OS/2 REXX Batch file  |  1999-07-08  |  2.2 KB  |  93 lines

  1.  
  2.  
  3. /* $VER: statickyupdate.rexx v1.0 (06.07.99)
  4.  
  5.    Amiga client for Staticky's dynamic DNS service
  6.    by Robert Wilson - robert@dynamix.force9.co.uk  - http://www.dynamix.force9.co.uk
  7.  
  8.    For more info on Staticky, please take a look at http://www.staticky.com
  9.    
  10.    If anyone wants to improve the rxsocket version and add timeout feature then
  11.    please do ;-) Personally I'm a bit confused by rxsocket at the moment :(
  12.  
  13.    Note: Please don't add code that requires additional libraries!
  14. */
  15.  
  16. /* start user settings */
  17.  
  18. userxsocket = 0
  19.  
  20. /* end user settings */
  21.  
  22. signal on BREAK_C
  23.  
  24. parse arg username' 'password' 'hostname
  25.  
  26. if username = '?' then help()
  27. if length(username) = 0 then die('Error! Check your username and try again!')
  28. if length(password) = 0 then die('Error! Check your password and try again!')
  29. if length(hostname) = 0 then hostname = username
  30.  
  31. string =  username':'password':'hostname'.staticky.com'
  32.  
  33. if userxsocket = 1 then call rxsocket()
  34. else call tcpdevice()
  35.  
  36. exit
  37.  
  38. /* rxsocket.library version */
  39.  
  40. rxsocket:
  41.  
  42. if ~show('l','rxsocket.library') then do
  43.   if ~addlib('rxsocket.library',0,-30,0) then die('Unable to add rxsocket.library')
  44. end
  45.  
  46. sock = openconnection('tcp','10980','dyndns.staticky.com')
  47.  
  48. if sock < 0 then do
  49.   select
  50.     when sock = -2 then die('Error! Unable to connect to Staticky''s server')
  51.     otherwise die('Error! Connection failed -' errorstring(errno()))
  52.   end
  53. end
  54.  
  55. if send(sock,string) ~= length(string) then call die('Error! -' errorstring(errno()))
  56.  
  57. chars = recv(sock,'ANSWER',1)
  58. if left(answer,1) ~= 'S' then die('Error! Update failed, check your settings and try again')
  59. else say 'Success - IP address updated ;-)'
  60.  
  61. return
  62.  
  63. /* tcp: device version */
  64.  
  65. tcpdevice:
  66.  
  67. if open(tcp,'TCP:dyndns.staticky.com/10980','w') then do
  68.   call writech(tcp,string)
  69.   answer = readch(tcp)
  70.   if answer ~= 'S' then die('Error! Update failed, check your settings and try again')
  71.   else say 'Success - IP address updated ;-)'
  72. end
  73. else die('Error! Unable to connect to Staticky''s server!')
  74.  
  75. return
  76.  
  77. /* common functions */
  78.  
  79. die:
  80. parse arg message
  81. say message
  82. exit 5
  83. return
  84.  
  85. help:
  86. say 'Usage ''rx statickyupdate.rexx username password [hostname]'''
  87. exit
  88. return
  89.  
  90. BREAK_C:
  91. call die('User break (CTRL-C)')
  92. return
  93.